﻿@{
    ViewBag.Title = "学生练习情况一览";
    Layout = "~/Views/Shared/_GridCommonLayout.cshtml";
}


<style>
    .red {
        color: red;
    }

    .green {
        color: green;
    }

    /*smart css本页面修改 by lx 2014/11/29 begin*/
    .price-features {
        background: none repeat scroll 0 0 #F7F7F7;
        font-size: 13.5px;
        min-height: 60px;
        padding: 20px 15px;
    }

    /*end*/

    .ground1 {
        background-color: #3276b1;
    }
    .ground2 {
        background-color: #609450;
    }
</style>
<!--begin grid code-->
<input type="hidden" value="@ViewBag.CourseID" id="courseId" />

 <!--Search-->
        <div class="filter-bar" hidden>
            <form id="formSearch">
                <input id='txtbSrICourseId' name='txtbSrICourseId' type='hidden' value="@ViewBag.CourseID" />
                <input id='txtbSrSStuCode' name='txtbSrSStuCode' type='hidden' value="@ViewBag.no" />                
            </form>
        </div>
    <!--/search-->




<section id="widget-grid" class="">
    <div class="row">
        <!--Operation-->
        <div class="heading-buttons">
            <div class="col-xs-12 col-sm-7 col-md-7 col-lg-4">
                <h1 class="page-title txt-color-blueDark"><i class="fa fa-desktop fa-fw "></i>
                    习题集			
                </h1>
            </div>
            <div style="clear: both;">
            </div>
        </div>
        <!--/Operation-->
    </div>
    <!--end row-->

    <!--Practice List -->
    <div class="row" data-bind="foreach: recordSet">
        <div class="col-xs-12 col-sm-6 col-md-3">
            <div class="panel panel-primary pricing-big">
                <img src="" class="ribbon" data-bind="attr:{src:$root.statusShow(IComplete)}">
                <div>
                <div class="panel-heading" data-bind="css:$root.currentStatu(IComplete)">
                    <h3 class="panel-title" data-bind='text: SPracticeName'></h3>
                </div>
                    </div>
                <div class="panel-body no-padding text-align-center">
                    <div class="the-price">
                        <h1 data-bind='text: IScore' style="color: white; display: inline;"></h1>
                        <span class="subscript">/ 100</span>
                    </div>
                    <div class="price-features">
                        <div class="buttons pull-right">
                            <button type="button" class="btn btn-success btn-labeled " data-bind="click: $root.DoPra">
                                <span class="btn-label"><i data-bind="css:$root.showImg(IComplete)"></i>
                                </span><span data-bind="text:$root.showFont(IComplete)"></span></button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--/Practice List end-->

</section>


<script type="text/javascript">

    var gdViewModel;
    $(function () {
        $._messengerDefaults = {
            extraClasses: 'messenger-fixed messenger-theme-future messenger-on-bottom messenger-on-right'
        }; //默认提示位置;

        var options = {

            dialogId: "StuPracticeMessageModal", //添加对话框

            pageSize: 20, //分页大小
            hidId: $("#txtbID"),
            SaveUpdateBtn: $("#btnSaveOrUpdateModel"),
            frmElement: $("#formStuPractice"),

            //节点数据
            NodeValue: ko.observable({

                Id: 0,
                SPracticeName: '',
                ICourseId: 0,
                SCouseCode: '',
                ITeaId: 0,
                STeaCode: '',
                ITermId: 0,
                IStuId: 0,
                SStuCode: '',
                IScore: 0,
                IPracticeId: 0,
                SClassCode: '',
                SClassName: '',
                SStuName: '',
                SCourseName: '',
                IComplete: 0,


            }),
            //默认的排序方式
            defaultOrderBy: "Id",
            //用户查询URL
            dataQueryUrlAccessor: function () {
                return "/api/StuPractice/GetByPage";
            },

            //添加用户URL
            dataAddUrlAccessor: function () { return "/api/StuPractice/Post"; },
            dataUpdateAccessor: function (key) { return "/api/StuPractice/Put/" + key; },
            dataNodeSelect: function (id) {
                return "/api/StuPractice/get/" + id;
            },

            dataDeleteAccessor: function (data) {
                var userIDs = "";
                var check = $("input:checked");  //得到所有被选中的checkbox
                check.each(function (i) {        //循环拼装被选中项的值
                    userIDs = userIDs + ',' + $(this).val();
                });
                //清除多余的分割号
                userIDs = dropRsplit(userIDs, ",");
                if (userIDs != "") {
                    return appendQueryString("/api/StuPractice/Delete", { ids: userIDs });
                } else
                    return "";

            }
			, initEd: function () {
			    //gird初始化的后置事件 信息

			}

        };

        gdViewModel = new gridViewModel(options);
        //转做练习题界面
        gdViewModel.DoPra = function (data) {
            if (data.IComplete == 1) {
                var url = "/Student/PracticeResult?PraId=" + data.IPracticeId;
                window.open(url, "_blank");
            }
            else {
                var url = "/Student/PracticeView?PraId=" + data.IPracticeId;
                window.open(url, "_blank");
            }

        }
        //习题图标转换
        gdViewModel.showImg = function (IComplete) {
            if (IComplete == 0) {//未完成
                return "glyphicon glyphicon-pencil";
            }
            else {//已完成
                return "glyphicon glyphicon-search";
            }
        }

        //习题完成状态图标的转换
        gdViewModel.statusShow = function (IComplete) {
            if (IComplete == 0) {//未完成
                return "/img/ribbon.png";
            }
            else {//已完成
                return "/img/ribbon2.png";
            }
        }

        //按钮文字显示
        gdViewModel.showFont = function (IComplete) {
            if (IComplete == 0) {//未完成
                return "练一练";
            }
            else {//已完成
                return "查看";
            }
        }

        //背景颜色
        gdViewModel.currentStatu = function (IComplete) {
            if (IComplete == 0) {//未完成
                return "ground1";
            }
            else {//已完成
                return "ground2";
            }
        }

        gdViewModel.init();
        ko.applyBindings(gdViewModel);
        

        options.frmElement.validate({
            rules: {

            },
            messages: {
            }
        });
    });
</script>

<!--/end grid code-->

